//**************************公用******************************//
$(function() {
	// 复选框全选反选
    $("#allcheck").click(function() {
        var isChecked = $(this).prop("checked");
        $("input[name='check']").prop("checked", isChecked);
    });
    //更改messager提示为中文
    $.extend($.messager.defaults,{
		ok:"确定",
		cancel:"取消"
	});

})

//根据矫正单位获取所有矫正人员
function allName() {
    var id = $('#addunit').val();
    $.ajax({
        url: "/rulebreak/getAllName",
        type: "get",
        dataType: "text",
        data: {
            id: id
        },
        success: function(result) {
            $('#allname').html(result);
        }
    })
}
// 批量删除所选
function alldelete(sort) {
	//获取所有name为check的复选框的数组
    var id = document.getElementsByName("check");
    //定义一个数组
    var ids = [];
    //定义一个变量,记录选中的复选框个数
    var i = 0;
    //遍历数组id
    for (k in id) {
    	//取选中的复选框的value属性,赋值给ids数组
        if (id[k].checked) {
            i++;
            ids.push(id[k].value);
        }
    }
    //如果选中的复选框数大于0,提示删除
    if (i > 0) {
        $.messager.confirm('提示框', '你确定要删除' + i + '条数据吗?',
        function(res) {
            if (res) {
                $.ajax({
                    url: "/" + sort + "/getDeleteIds",
                    traditional: true,
                    type: "get",
                    dataType: "text",
                    data: {
                        id: ids
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '删除' + i + '条数据成功!',
                            icon: 'info'
                        });
                        $("input[name='check']").prop("checked", false);
                        $("input[name='allcheck']").prop("checked", false);
                        if (sort == "monthtest") {
                            getMonthTestList(1,10);
                        } else if (sort == "activist") {
                            getActivistList(1,10);
                        } else if (sort == "bonuspoints") {
                            getBonusPointsList(1,10);
                        } else if (sort == "rulebreak") {
                            getRuleBreakList(1,10);
                        } else {
                            getRewordPunishList(1,10);
                        }
                    }
                })
            } else {
                // 取消删除
            }
        })
    //如果选中的复选框数小于0,提示未选中复选框
    } else {
        $.messager.alert({
            title: '消息',
            msg: '请至少选择一项!',
            icon: 'info'
        });
    }
}

// 批量导出所选
function exportchoice(sort) {
    var id = document.getElementsByName("check");
    var ids = [];
    var i = 0;
    for (k in id) {
        if (id[k].checked) {
            i++;
            ids.push(id[k].value);
        }
    }
    if (i > 0) {
        $.messager.confirm('提示框', '你确定要导出' + i + '条数据吗?',
        function(res) {
            if (res) {
                var url = "/"+sort+"/exportExcel?id=" + ids;
                window.open(url);
                $("input[name='check']").prop("checked", false);
                $("input[name='allcheck']").prop("checked", false);
            } else {
                // 取消删除
            }
        })
    } else {
        $.messager.alert({
            title: '消息',
            msg: '请至少选择一项!',
            icon: 'info'
        });
    }
}

//加载柱状图
var loadchart = function() {
	$.ajax({
		url : "/rulebreak/gettimes",
		type : "get",
		dataType : "json",
		success : function(result) {
			// 基于准备好的dom，初始化echarts实例
			var myChart = echarts.init(document.getElementById('main'));
			// 指定图表的配置项和数据
			var option = {
				title : {
					text : '违规次数统计'
				},
				tooltip : {},
				legend : {
					data : [ '违规次数' ]
				},
				xAxis : {
					data : result.date
				},
				yAxis : {},
				series : [ {
					name : '违规次数',
					type : 'bar',
					itemStyle: {
               			 normal: {
                    color: function(params) {
                        var colorList = ['#5978A3'
                        ];
                        return colorList[params.dataIndex]
                    }
                }
            },
　　　　　　//设置柱的宽度，要是数据太少，柱子太宽不美观~
　　　　　　barWidth:70,
					data : result.times
				} ]
			};
			// 使用刚指定的配置项和数据显示图表。
			myChart.setOption(option);
		}
	})
}
// **************************月度考核***************************//
// 导出Excel
function downloadMonthTest() {
    var url = "/monthtest/exportExcel";
    window.open(url);
}

// 模糊查询分页列表
var getMonthTestList = function(curr, cur) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/monthtest/querylike",
        data: {
            pageNum: curr || 1,
            pageSize: cur || 10,
            cunit: $("#cunit").val(),
            cname: $("#cname").val(),
            cdate: $("#cmonth").val(),
            cclazz: $("#clevel").val()
        },
        // 显示分页
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('monthtest');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('monthtest');
                    }
                }],
                pageSize: cur,
                pageNumber: curr,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
                onSelectPage: function(pageNumber, pageSize) {
                    getMonthTestList(pageNumber, pageSize);
                }
            });
        }
    });
}

// 模糊查询月度考核记录
var queryMonthTest = function() {
	getMonthTestList(1,10);
  
}

// 增加月度考核记录
var addMonthTest = function() {
    $('#addmonthtest').dialog({
        title: '增加---月度考核记录',
        width: 600,
        height: 310,
        closed: false,
        cache: false,
        href: '/rulebreak/allunit?sort=monthtest',
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/monthtest/addMonthTest",
                    type: "get",
                    dataType: "json",
                    data: {
                        "pid": $("#allname").val(),
                        "month": $("#addmonth").val(),
                        "level": $("#addlevel").val(),
                        "points": $("#addpoints").val(),
                        "summary": $("#addsummary").val(),
                        "opinion": $("#addopinion").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '保存成功!',
                            icon: 'info'
                        });
                        getMonthTestList();
                        $('#addmonthtest').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#addmonthtest').dialog('close');
            }
        }]
    });
}

// 修改月度考核记录
var editMonthTest = function(id) {
    $('#editmonthtest').dialog({
        title: '修改---月度考核记录',
        width: 600,
        height: 310,
        closed: false,
        cache: false,
        href: '/monthtest/detail?sort=edit&id=' + id,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/monthtest/updateMonthTest",
                    type: "get",
                    dataType: "json",
                    data: {
                        "id": $("#editid").val(),
                        "month": $("#editmonth").val(),
                        "level": $("#editlevel").val(),
                        "points": $("#editpoints").val(),
                        "summary": $("#editsummary").val(),
                        "opinion": $("#editopinion").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '修改成功!',
                            icon: 'info'
                        });
                        getMonthTestList();
                        $('#editmonthtest').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#editmonthtest').dialog('close');
            }
        }]
    });
}

// 查看月度考核记录详情
var checkMonthTest = function(id) {
    $('#checkmonthtest').dialog({
        title: '查看---月度考核记录详情',
        width: 600,
        height: 380,
        closed: false,
        cache: false,
        href: '/monthtest/detail?sort=check&id=' + id,
        modal: true,
        buttons: [{
            text: '关闭',
            handler: function() {
                $('#checkmonthtest').dialog('close');
            }
        }]
    });

}

// 删除月度考核记录
var delMonthTest = function(id) {
    $.messager.confirm('提示框', '你确定要删除吗?',
    function(res) {
        if (res) {
            $.ajax({
                url: "/monthtest/delMonthTest",
                type: "get",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(result) {
                    $.messager.alert({
                        title: '消息',
                        msg: '删除成功!',
                        icon: 'info'
                    });
                    getMonthTestList(1,10);
                }
            });
        } else {
            // 取消删除
        }
    })
}

// **************************违规违纪***************************//
// 导出Excel
function downloadRuleBreak() {
    var url = "/rulebreak/exportExcel";
    window.open(url);
}

// 模糊查询分页列表
var getRuleBreakList = function(curr, cur) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/rulebreak/querylike",
        data: {
            pageNum: curr || 1,
            pageSize: cur || 10,
            cunit: $("#cunit").val(),
            cname: $("#cname").val(),
            cdate: $("#cdate").val()
        },
        // 显示分页
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('rulebreak');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('rulebreak');
                    }
                }],
                pageSize: cur,
                pageNumber: curr,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
                onSelectPage: function(pageNumber, pageSize) {
                    getRuleBreakList(pageNumber, pageSize);
                }
            });
        }
    });
}

// 模糊查询违规违纪记录
var queryRuleBreak = function() {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/rulebreak/querylike",
        data: {
            pageNum: 1,
            pageSize: 10,
        },
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('rulebreak');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('rulebreak');
                    }
                }],
                pageSize: 10,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
            });
            getRuleBreakList();
        }
    });
}

// 增加违规违纪记录
var addRuleBreak = function() {
    $('#addrulebreak').dialog({
        title: '增加---违规违纪记录',
        width: 600,
        height: 360,
        closed: false,
        cache: false,
        href: '/rulebreak/allunit?sort=rulebreak',
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/rulebreak/addRuleBreak",
                    type: "get",
                    dataType: "json",
                    data: {
                        "pid": $("#allname").val(),
                        adddate: $("#adddate").val(),
                        "fact": $("#fact").val(),
                        "solution": $("#solution").val(),
                        "remark": $("#remark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '保存成功!',
                            icon: 'info'
                        });
                        getRuleBreakList();
                        $('#addrulebreak').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#addrulebreak').dialog('close');
            }
        }]
    });
}

// 修改违规违纪记录
var editRuleBreak = function(id) {
    $('#editrulebreak').dialog({
        title: '修改---违规违纪记录',
        width: 600,
        height: 360,
        closed: false,
        cache: false,
        href: '/rulebreak/detail?sort=edit&id=' + id,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/rulebreak/updateRuleBreak",
                    type: "get",
                    dataType: "json",
                    data: {
                        "id": $("#editid").val(),
                        editdate: $("#editdate").val(),
                        "fact": $("#editfact").val(),
                        "solution": $("#editsolution").val(),
                        "remark": $("#editremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '修改成功!',
                            icon: 'info'
                        });
                        getRuleBreakList();
                        $('#editrulebreak').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#editrulebreak').dialog('close');
            }
        }]
    });

}

// 查看违规违纪记录详情
var checkRuleBreak = function(id) {
    $('#checkrulebreak').dialog({
        title: '查看---违规违纪记录详情',
        width: 600,
        height: 360,
        closed: false,
        cache: false,
        href: '/rulebreak/detail?sort=check&id=' + id,
        modal: true,
        buttons: [{
            text: '关闭',
            handler: function() {
                $('#checkrulebreak').dialog('close');
            }
        }]
    });

}

// 删除违规违纪记录
var delRuleBreak = function(id) {
    $.messager.confirm('提示框', '你确定要删除吗?',
    function(res) {
        if (res) {
            $.ajax({
                url: "/rulebreak/delRuleBreak",
                type: "get",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(result) {
                    $.messager.alert({
                        title: '消息',
                        msg: '删除成功!',
                        icon: 'info'
                    });
                    getRuleBreakList(1,10);
                }
            });
        } else {
            // 取消删除
        }
    })
}

// **************************积极分子***************************//
// 导出Excel
function downloadActivist() {
    var url = "/activist/exportExcel";
    window.open(url);
}

// 模糊查询分页列表
var getActivistList = function(curr, cur) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/activist/querylike",
        data: {
            pageNum: curr || 1,
            pageSize: cur || 10,
            cunit: $("#cunit").val(),
            cname: $("#cname").val(),
            cclazz: $("#cclazz").val()
        },
        // 显示分页
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('activist');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('activist');
                    }
                }],
                pageSize: cur,
                pageNumber: curr,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
                onSelectPage: function(pageNumber, pageSize) {
                    getActivistList(pageNumber, pageSize);
                }
            });
        }
    });
}

// 模糊积极分子违纪记录
var queryActivist = function() {
	getActivistList(1,10);
}

// 增加积极分子记录
var addActivist = function() {
    $('#addactivist').dialog({
        title: '增加---积极分子记录',
        width: 600,
        height: 330,
        closed: false,
        cache: false,
        href: '/rulebreak/allunit?sort=activist',
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/activist/addActivist",
                    type: "get",
                    dataType: "json",
                    data: {
                        "pid": $("#allname").val(),
                        "clazz": $("#addclazz").val(),
                        "reason": $("#addreason").val(),
                        "remark": $("#addremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '保存成功!',
                            icon: 'info'
                        });
                        getActivistList();
                        $('#addactivist').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#addactivist').dialog('close');
            }
        }]
    });
}

// 修改积极分子记录
var editActivist = function(id) {
    $('#editactivist').dialog({
        title: '修改---积极分子记录',
        width: 600,
        height: 330,
        closed: false,
        cache: false,
        href: '/activist/detail?sort=edit&id=' + id,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/activist/updateActivist",
                    type: "get",
                    dataType: "json",
                    data: {
                        "id": $("#editid").val(),
                        "clazz": $("#editclazz").val(),
                        "opinion": $("#editopinion").val(),
                        "reason": $("#editreason").val(),
                        "remark": $("#editremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '修改成功!',
                            icon: 'info'
                        });
                        getActivistList();
                        $('#editactivist').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#editactivist').dialog('close');
            }
        }]
    });

}

// 查看积极分子记录详情
var checkActivist = function(id) {
    $('#checkactivist').dialog({
        title: '查看---积极分子记录详情',
        width: 600,
        height: 330,
        closed: false,
        cache: false,
        href: '/activist/detail?sort=check&id=' + id,
        modal: true,
        buttons: [{
            text: '关闭',
            handler: function() {
                $('#checkactivist').dialog('close');
            }
        }]
    });

}

// 删除积极分子记录
var delActivist = function(id) {
    $.messager.confirm('提示框', '你确定要删除吗?',
    function(res) {
        if (res) {
            $.ajax({
                url: "/activist/delActivist",
                type: "get",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(result) {
                    $.messager.alert({
                        title: '消息',
                        msg: '删除成功!',
                        icon: 'info'
                    });
                    getActivistList(1,10);
                }
            });
        } else {
            // 取消删除
        }
    })
}
// **************************奖励惩罚***************************//
// 导出Excel
function downloadRewordPunish() {
    var url = "/rewordpunish/exportExcel";
    window.open(url);
}

// 模糊查询分页列表
var getRewordPunishList = function(curr, cur) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/rewordpunish/querylike",
        data: {
            pageNum: curr || 1,
            pageSize: cur || 10,
            cunit: $("#cunit").val(),
            cname: $("#cname").val(),
            cdate: $("#cdate").val(),
            cclazz: $("#cclazz").val()
        },
        // 显示分页
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('rewordpunish');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('rewordpunish');
                    }
                }],
                pageSize: cur,
                pageNumber: curr,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
                onSelectPage: function(pageNumber, pageSize) {
                    getRewordPunishList(pageNumber, pageSize);
                }
            });
        }
    });
}

// 模糊查询奖励惩罚记录
var queryRewordPunish = function() {
	 getRewordPunishList(1,10);
}

// 增加奖励惩罚记录
var addRewordPunish = function() {
    $('#addrewordpunish').dialog({
        title: '增加---奖励惩罚记录',
        width: 600,
        height: 345,
        closed: false,
        cache: false,
        href: '/rulebreak/allunit?sort=rewordpunish',
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/rewordpunish/addRewordPunish",
                    type: "get",
                    dataType: "json",
                    data: {
                        "pid": $("#allname").val(),
                        adddate: $("#adddate").val(),
                        "clazz": $("#addclazz").val(),
                        "status": $("#addstatus").val(),
                        "content": $("#addcontent").val(),
                        "remark": $("#addremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '保存成功!',
                            icon: 'info'
                        });
                        getRewordPunishList();
                        $('#addrewordpunish').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#addrewordpunish').dialog('close');
            }
        }]
    });
}

// 修改奖励惩罚记录
var editRewordPunish = function(id) {
    $('#editrewordpunish').dialog({
        title: '修改---奖励惩罚记录',
        width: 600,
        height: 345,
        closed: false,
        cache: false,
        href: '/rewordpunish/detail?sort=edit&id=' + id,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/rewordpunish/updateRewordPunish",
                    type: "get",
                    dataType: "json",
                    data: {
                        "id": $("#editid").val(),
                        editdate: $("#editdate").val(),
                        "clazz": $("#editclazz").val(),
                        "status": $("#editstatus").val(),
                        "content": $("#editcontent").val(),
                        "remark": $("#editremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '修改成功!',
                            icon: 'info'
                        });
                        getRewordPunishList();
                        $('#editrewordpunish').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#editrewordpunish').dialog('close');
            }
        }]
    });

}

// 查看奖励惩罚记录详情
var checkRewordPunish = function(id) {
    $('#checkrewordpunish').dialog({
        title: '查看---奖励惩罚记录详情',
        width: 600,
        height: 345,
        closed: false,
        cache: false,
        href: '/rewordpunish/detail?sort=check&id=' + id,
        modal: true,
        buttons: [{
            text: '关闭',
            handler: function() {
                $('#checkrewordpunish').dialog('close');
            }
        }]
    });

}

// 删除奖励惩罚记录
var delRewordPunish = function(id) {
    $.messager.confirm('提示框', '你确定要删除吗?',
    function(res) {
        if (res) {
            $.ajax({
                url: "/rewordpunish/delRewordPunish",
                type: "get",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(result) {
                    $.messager.alert({
                        title: '消息',
                        msg: '删除成功!',
                        icon: 'info'
                    });
                    getRewordPunishList(1,10);
                }
            });
        } else {
            // 取消删除
        }
    })
}

// **************************加分扣分***************************//
// 导出Excel
function downloadBonusPoints() {
    var url = "/bonuspoints/exportExcel";
    window.open(url);
}

// 模糊查询分页列表
var getBonusPointsList = function(curr, cur) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: "/bonuspoints/querylike",
        data: {
            pageNum: curr || 1,
            pageSize: cur || 10,
            cunit: $("#cunit").val(),
            cname: $("#cname").val(),
            cdate: $("#cdate").val(),
            cclazz: $("#cclazz").val()
        },
        // 显示分页
        success: function(msg) {
            app.result = msg.result;
            $('#pagediv').pagination({
                total: msg.totalNum,
                buttons: [{
                    text: '删除所选',
                    iconCls: 'icon-cut',
                    handler: function() {
                        alldelete('bonuspoints');
                    }
                },
                {
                    text: '导出所选',
                    iconCls: 'icon-save',
                    handler: function() {
                        exportchoice('bonuspoints');
                    }
                }],
                pageSize: cur,
                pageNumber: curr,
                pageList: [1, 5, 10, 15, 20],
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                layout: ['list', 'sep', 'first', 'prev', 'links', 'next', 'last', 'sep', 'refresh', 'manual'],
                displayMsg: '当前显示第 {from} 至  第 {to} 条记录   共 {total} 条记录',
                onSelectPage: function(pageNumber, pageSize) {
                    getBonusPointsList(pageNumber, pageSize);
                }
            });
        }
    });
}

// 模糊查询加分扣分记录
var queryBonusPoints = function() {
	getBonusPointsList(1,10);
}

// 增加加分扣分记录
var addBonusPoints = function() {
    $('#addbonuspoints').dialog({
        title: '增加---加分扣分记录',
        width: 650,
        height: 370,
        closed: false,
        cache: false,
        href: '/rulebreak/allunit?sort=bonuspoints',
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/bonuspoints/addBonusPoints",
                    type: "get",
                    dataType: "json",
                    data: {
                        "jid": $("#addunit").val(),
                        "pid": $("#allname").val(),
                        adddate: $("#adddate").val(),
                        "clazz": $("#addclazz").val(),
                        "point": $("#addpoint").val(),
                        "reason": $("#addreason").val(),
                        "opinion": $("#addopinion").val(),
                        "remark": $("#addremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '保存成功!',
                            icon: 'info'
                        });
                        getBonusPointsList();
                        $('#addbonuspoints').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#addbonuspoints').dialog('close');
            }
        }]
    });
}

// 修改加分扣分记录
var editBonusPoints = function(id) {
    $('#editbonuspoints').dialog({
        title: '修改---加分扣分记录',
        width: 650,
        height: 370,
        closed: false,
        cache: false,
        href: '/bonuspoints/detail?sort=edit&id=' + id,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: 'icon-ok',
            handler: function() {
                $.ajax({
                    url: "/bonuspoints/updateBonusPoints",
                    type: "get",
                    dataType: "json",
                    data: {
                        "id": $("#editid").val(),
                        editdate: $("#editdate").val(),
                        "clazz": $("#editclazz").val(),
                        "point": $("#editpoint").val(),
                        "reason": $("#editreason").val(),
                        "opinion": $("#editopinion").val(),
                        "remark": $("#editremark").val()
                    },
                    success: function(result) {
                        $.messager.alert({
                            title: '消息',
                            msg: '修改成功!',
                            icon: 'info'
                        });
                        getBonusPointsList();
                        $('#editbonuspoints').dialog('close');
                    }
                });
            }
        },
        {
            text: '关闭',
            handler: function() {
                $('#editbonuspoints').dialog('close');
            }
        }]
    });

}

// 查看加分扣分记录详情
var checkBonusPoints = function(id) {
    $('#checkbonuspoints').dialog({
        title: '查看---加分扣分记录详情',
        width: 650,
        height: 370,
        closed: false,
        cache: false,
        href: '/bonuspoints/detail?sort=check&id=' + id,
        modal: true,
        buttons: [{
            text: '关闭',
            handler: function() {
                $('#checkbonuspoints').dialog('close');
            }
        }]
    });
}

// 删除加分扣分记录
var delBonusPoints = function(id) {
    $.messager.confirm('提示框', '你确定要删除吗?',
    function(res) {
        if (res) {
            $.ajax({
                url: "/bonuspoints/delBonusPoints",
                type: "get",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(result) {
                    $.messager.alert({
                        title: '消息',
                        msg: '删除成功!',
                        icon: 'info'
                    });
                    getBonusPointsList(1,10);
                }
            });
        } else {
            // 取消删除
        }
    })
}